﻿using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace SvnDeploy.Service.Impl
{
    internal class FileSystemImpl : IFileSystem
    {
        public void CreateDirectory(string directory)
        {
            Directory.CreateDirectory(directory);            
        }

        public void DeleteFile(string file)
        {
            File.Delete(file);
        }

        public bool DoesDirectoryExist(string directory)
        {
            return Directory.Exists(directory);
        }

        public IEnumerable<FileInfo> GetFiles(string directory)
        {            
            return Directory.EnumerateFiles(directory).Select(f => new FileInfo(f));
        }

        public bool IsDirectoryEmpty(string directory)
        {
            return !Directory.EnumerateFiles(directory).Any();
        }
    }
}
